﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;


namespace FAP.DataAccess.BLL
{
    public class buocthuchien
    {
        public int id { get; set; }
        public int thutu { get; set; }
        public int trangthai { get; set; }
        public int chitietnghiepvuid { get; set; }
        public string link { get; set; }
        public string method { get; set; }
        public bool isdeleted { get; set; }
        //public chitietnghiepvu chitietnghiepvu { get { return chitietnghiepvu.chitietnghiepvuSelectRow(chitietnghiepvuid); } }
        //public List<chitietbuocthuchien> chitietbuocthuchiens { get { return chitietbuocthuchien.chitietbuocthuchienSelectRowByForeignKey_idbuocthuchien(id); } }

        #region buocthuchienSelectAll
        public static List<buocthuchien> buocthuchienSelectAll()
        {
            IDataReader dr = FAP.DataAccess.DAL.buocthuchienSelectAll();
            List<buocthuchien> buocthuchienList = new List<buocthuchien>();
            while (dr.Read())
            {
                buocthuchien mybuocthuchien = new buocthuchien
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    thutu = !dr.IsDBNull(dr.GetOrdinal("thutu")) ? (int)dr["thutu"] : 0,
                    trangthai = !dr.IsDBNull(dr.GetOrdinal("trangthai")) ? (int)dr["trangthai"] : 0,
                    chitietnghiepvuid = !dr.IsDBNull(dr.GetOrdinal("chitietnghiepvuid")) ? (int)dr["chitietnghiepvuid"] : 0,
                    link = !dr.IsDBNull(dr.GetOrdinal("link")) ? (string)dr["link"] : null,
                    method = !dr.IsDBNull(dr.GetOrdinal("method")) ? (string)dr["method"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false
                };
                buocthuchienList.Add(mybuocthuchien);
            }
            dr.Close();
            dr.Dispose();
            return buocthuchienList;
        }
        #endregion

        #region buocthuchienSelectRow
        public static buocthuchien buocthuchienSelectRow(int id)
        {
            IDataReader dr = FAP.DataAccess.DAL.buocthuchienSelectRow(id);
            buocthuchien buocthuchien = null;

            if (dr.Read())
            {
                buocthuchien = new buocthuchien
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    thutu = !dr.IsDBNull(dr.GetOrdinal("thutu")) ? (int)dr["thutu"] : 0,
                    trangthai = !dr.IsDBNull(dr.GetOrdinal("trangthai")) ? (int)dr["trangthai"] : 0,
                    chitietnghiepvuid = !dr.IsDBNull(dr.GetOrdinal("chitietnghiepvuid")) ? (int)dr["chitietnghiepvuid"] : 0,
                    link = !dr.IsDBNull(dr.GetOrdinal("link")) ? (string)dr["link"] : null,
                    method = !dr.IsDBNull(dr.GetOrdinal("method")) ? (string)dr["method"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false,

                };
            }
            dr.Close();
            dr.Dispose();
            return buocthuchien;
        }
        #endregion

        #region buocthuchienSelectRowByForeignKey_chitietnghiepvuid
        public static List<buocthuchien> buocthuchienSelectRowByForeignKey_chitietnghiepvuid(int chitietnghiepvuid)
        {
            IDataReader dr = FAP.DataAccess.DAL.buocthuchienSelectRowByForeignKey_chitietnghiepvuid(chitietnghiepvuid);
            List<buocthuchien> buocthuchienList = new List<buocthuchien>();
            while (dr.Read())
            {
                buocthuchien mybuocthuchien = new buocthuchien
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    thutu = !dr.IsDBNull(dr.GetOrdinal("thutu")) ? (int)dr["thutu"] : 0,
                    trangthai = !dr.IsDBNull(dr.GetOrdinal("trangthai")) ? (int)dr["trangthai"] : 0,
                    chitietnghiepvuid = !dr.IsDBNull(dr.GetOrdinal("chitietnghiepvuid")) ? (int)dr["chitietnghiepvuid"] : 0,
                    link = !dr.IsDBNull(dr.GetOrdinal("link")) ? (string)dr["link"] : null,
                    method = !dr.IsDBNull(dr.GetOrdinal("method")) ? (string)dr["method"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false
                };
                buocthuchienList.Add(mybuocthuchien);
            }
            dr.Close();
            dr.Dispose();
            return buocthuchienList;
        }
        #endregion

        #region buocthuchienInsertRow
        public static int buocthuchienInsertRow(int thutu, int trangthai, int chitietnghiepvuid, string link, string method, bool isdeleted)
        {
            var re =FAP.DataAccess.DAL.buocthuchienInsertRow(thutu, trangthai, chitietnghiepvuid, link, method, isdeleted);
            if (re == null)
                return 0;
            return (int)re;
        }
        #endregion

        #region buocthuchienUpdateRow
        public static void buocthuchienUpdateRow(int id, int thutu, int trangthai, int chitietnghiepvuid, string link, string method, bool isdeleted)
        {
            FAP.DataAccess.DAL.buocthuchienUpdateRow(id, thutu, trangthai, chitietnghiepvuid, link, method, isdeleted);
        }
        #endregion

        #region buocthuchienDeleteRow
        public static void buocthuchienDeleteRow(int id)
        {
            FAP.DataAccess.DAL.buocthuchienDeleteRow(id);
        }
        #endregion
    }
}